package 打怪;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int T = in.nextInt();
        while (T-- > 0) {
            int h = in.nextInt();
            int a = in.nextInt();
            int H = in.nextInt();
            int A = in.nextInt();
            if (a >= H) {
                System.out.println(-1);
            } else {
                //遇到一只怪物时，怪物能抗几次
                int n = H / a + (H % a == 0 ? 0 : 1);
                //遇到一只怪物时，玩家要抗几次
                int m = n - 1;
                //遇到一只怪物时,受到的伤害
                int x = A * m;
                //杀了几只怪
                int y = h / x - (h % x == 0 ? 1 : 0);
                System.out.println(y);
            }
        }
    }
}
